package com.mxchip.livestar.ui.network.wifi.widget.base;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import com.mxchip.livestar.R;


public abstract class Dialog extends android.app.Dialog {

    protected  View inflate = null;
    public Dialog(Context context) {
        this(context, R.style.common_dialog_transparent_shadowed);
    }

    public Dialog(Context context, int themeResId) {
        super(context, R.style.common_dialog_transparent_shadowed);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        int layout = getLayout();
          inflate = LayoutInflater.from(getContext()).inflate(layout, null);
        setContentView(inflate);
        initView();
    }

    protected abstract int getLayout();

    protected void initView() {
    }

    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity = Gravity.CENTER;
        layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().setAttributes(layoutParams);
    }
}
